package com.ganee.agora.viewmodel;

import android.app.Application;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.ganee.agora.model.HomeListBean;
import com.ganee.agora.model.UserInfoEntity;
import com.ganee.baselib.httprequest.callback.RequestCallback;
import com.ganee.baselib.httprequest.callback.RequestMultiplyCallback;
import com.ganee.baselib.httprequest.exception.ApiException;
import com.ganee.baselib.mvvmlibrary.base.BaseViewModel;
import com.ganee.agora.repository.MainRepository;

import java.util.List;

public class MainViewModel extends BaseViewModel<MainRepository> {
    private MutableLiveData<List<HomeListBean>> liveData = new MutableLiveData<>();
    public MutableLiveData<UserInfoEntity> getUserInfoEntity = new MutableLiveData<>();

    public MainViewModel(@NonNull Application application) {
        super(application);
    }

    @Override
    protected MainRepository getRepository() {
        return new MainRepository(this);
    }


    //获取用户信息
    public void getUserInfo() {
        mRepository.getUserInfo(new RequestCallback<UserInfoEntity>() {

            @Override
            public void onSuccess(UserInfoEntity userInfoEntity) {
                getUserInfoEntity.setValue(userInfoEntity);
            }
        });
    }

    public MutableLiveData<List<HomeListBean>> getMutableLiveData() {
        return liveData;
    }
}
